/**   
 * 文件名：PostVO.java</br>
 * 描述： </br>
 * 开发人员：汪浩博 </br>
 * 创建时间： 2016-5-20
 */ 

package com.post.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.base.util.BeanUtil;
import com.topic.bean.Topic;
import com.user.bean.BBSUser;
import com.user.service.UserService;

/** 
 * 类名: PostVO</br> 
 * 包名：com.post.bean </br> 
 * 描述: </br>
 * 发布版本号：</br>
 * 开发人员： 汪浩博</br>
 * 创建时间： 2016-5-20 
 */

public class PostVO implements Serializable{
	private String id;			//帖子id
	private String topicId;		//主题id
	private String postTime;	//发帖时间
	private String title;		//标题
	private String content;		//内容
	private String userId;		//用户id
	private String postStatus;	//帖子状态  未审核0 未通过审核 1 ，通过审核 2 ，加精 3
	private String provinces;	//所属省份
	private String area;		//所属地区
	private Integer viewNumber;	//查看数
	private Integer replyNumber;//回复数
	private String lastreplytime;//最近回复时间
	
	private Long uid;			//用户id
	private String nickName;	//昵称
	private String topicName;	//主题名
	private String headImg;	 	//用户头像地址
	
	public PostVO() {
		
	}
	
	public List<PostVO> beanTransVo(List<Post> queryResult,UserService userService){
		ArrayList<PostVO> list = new ArrayList<PostVO>();
		for (Post post : queryResult) {
			String userId = post.getUserId();
			BBSUser bbsUser = userService.findUserById(userId);
			PostVO postVO = new PostVO();
			//属性拷贝
			BeanUtil.copyProperties(postVO, post);
			postVO.setUid(Long.parseLong(userId));
			postVO.setNickName(bbsUser.getNickName());
			postVO.setHeadImg(bbsUser.getHeadImg());
			
			list.add(postVO);
		}
		return list;
	}
	/** 
	 * 方法名: initPostVO</br>
	 * 详述: 将结果集转换为PostVO</br>
	 * 开发人员：汪浩博</br>
	 * 创建时间：2016-6-5</br>
	 * @param next  多表关联查询得到的对象数组
	 */ 
	public PostVO initPostVO(Object[] next) {
		Post post = (Post) next[0];
		BBSUser user = (BBSUser) next[1];
		Topic topic = (Topic) next[2];
		
		PostVO postVO = new PostVO();
		
		BeanUtil.copyProperties(postVO, post);
		
		postVO.setUid(Long.parseLong(post.getUserId()));
		postVO.setNickName(user.getNickName());
		postVO.setHeadImg(user.getHeadImg());
		postVO.setTopicName(topic.getTopicName());
		
		return postVO;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTopicId() {
		return topicId;
	}

	public void setTopicId(String topicId) {
		this.topicId = topicId;
	}

	public String getPostTime() {
		return postTime;
	}

	public void setPostTime(String postTime) {
		this.postTime = postTime;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPostStatus() {
		return postStatus;
	}

	public void setPostStatus(String postStatus) {
		this.postStatus = postStatus;
	}

	public String getProvinces() {
		return provinces;
	}

	public void setProvinces(String provinces) {
		this.provinces = provinces;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public Integer getViewNumber() {
		return viewNumber;
	}

	public void setViewNumber(Integer viewNumber) {
		this.viewNumber = viewNumber;
	}

	public Integer getReplyNumber() {
		return replyNumber;
	}

	public void setReplyNumber(Integer replyNumber) {
		this.replyNumber = replyNumber;
	}

	public String getLastreplytime() {
		return lastreplytime;
	}

	public void setLastreplytime(String lastreplytime) {
		this.lastreplytime = lastreplytime;
	}

	public Long getUid() {
		return uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public String getHeadImg() {
		return headImg;
	}

	public void setHeadImg(String headImg) {
		this.headImg = headImg;
	}

	public String getTopicName() {
		return topicName;
	}

	public void setTopicName(String topicName) {
		this.topicName = topicName;
	}
	
}
